select top 100 * from  formtable_main_61

where  REQUESTID= 1290930

select * from formtable_main_837    test20250809

select * from formtable_main_837_dt1


select top 100 * from formtable_main_61  ORDER BY id desc

SELECT TOP 100 * FROM formtable_main_735 ORDER BY id desc

select  * from  formtable_main_758 c where c.ecrbh in(

SELECT   * FROM formtable_main_735 a where   EXISTS   (select  1 from formtable_main_758 b where b.ecrbh=a.ecr_no) and a.zfbs='F')


SELECT   a.ecr_no ,a.zfbs FROM formtable_main_735 a where   EXISTS   (select  1 from formtable_main_758 b where b.ecrbh=a.ecr_no) and a.zfbs='F'


update set  from formtable_main_735 a , formtable_main_758 b where  EXISTS   (select  1 from formtable_main_758 b where b.ecrbh=a.ecr_no) and a.zfbs='F'

1305609
UPDATE a
SET a.zfbs = 'T'
FROM formtable_main_735 a
WHERE EXISTS (SELECT 1 FROM formtable_main_758 b WHERE b.ecrbh = a.ecr_no)
AND a.zfbs = 'F';


UPDATE t1
SET t1.column1 = t2.column1,
    t1.column2 = t2.column2
FROM Table1 t1
INNER JOIN Table2 t2 ON t1.key = t2.key
WHERE [条件];



update formtable_main_735  set zfbs='T' where ECR_NO='ZHRD-202507535' ---已经更新


update  formtable_main_735 set  zfbs='T' where ecr_no='{?ecrbh}'

SELECT zfbs FROM formtable_main_735 a   where a.ECR_NO='ZHRD-202507535'


select top 100 * from formtable_main_699 order by requestid desc  where sydh='JGRD2025042801-021'ORDER BY id desc
 
select  sfjy,* from formtable_main_699 where requestid=1297153    ORDER BY id desc ECR_NO='ZHRD-202509247' ORDER BY id desc
 formtable_main_707_dt1

SELECT TOP 100  * FROM workflow_formdetail

select  Top 100 a.* ,b.lastname from  workflow_currentoperator a left join HrmResource b on a.userid=b.id where  REQUESTID=1310141  

o1 主要存储当前待办任务


select top 100 * from workflow_nodebase o2 where id= 2400  流程节点基础信息名称


SELECT TOP 100 * FROM workflow_requestlog WHERE REQUESTID= 1312422  查流程编号


SELECT b.NODENAME,a.* FROM workflow_requestlog a 
left join workflow_nodebase b on a.nodeid=b.id WHERE a.REQUESTID= 1291334 order by operatetime asc 查询流程各节点名称执行时间


select * from workflow_requestbase WHERE REQUESTID=1297153  and workflowid=2400 查流程在哪个节点的表 当前节点
 
 workflowid=2400
select  Top 100 *  from  workflow_currentoperator  WHERE REQUESTID=1310147


select top 100 * from workflow_flowchart 


select top 100 * from workflow_base  where id =2391 流程基础信息表 根据流程编号查流程各种信息如流程名称

select requestid,createdate+' '+createtime 创建时间 from  workflow_requestbase where requestid=1310147

select top 100 * from workflow_flownode
select * from formtable_main_699 where dh='20250909005' order by id desc   20250909005

select top 100  * from workflow_flownode - 流程节点表

select top 100 * from workflow_requestlog  where requestid=1309066

select a.requestid,b.lastname from  workflow_requestbase a left join  HrmResource b on a.lastoperator=b.id  where requestid=1308377


select * from  workflow_action where actionname='ZH_YFSY_XQ'

(actionname, interfacename, interfacetype)
VALUES('你的动作名称', 'ZH_YFSY_XQ', '1');


SELECT 
    r.requestid AS '流程请求ID',
    r.requestname AS '流程标题',
    w.workflowname AS '流程名称',
    n.nodename AS '当前节点',
    h.lastname AS '待办人',
    CASE 
        WHEN c.isremark = 0 THEN '未操作' 
        WHEN c.isremark = 2 THEN '已操作' 
        WHEN c.isremark = 4 THEN '归档'
        WHEN c.isremark = 1 THEN '转发' 
        WHEN c.isremark = 8 THEN '抄送' 
        ELSE '其他' 
    END AS '操作类型',
    c.receivedate + ' ' + c.receivetime AS '单据到达时间'
FROM workflow_requestbase r
INNER JOIN workflow_base w ON r.workflowid = w.id
INNER JOIN workflow_currentoperator c ON r.requestid = c.requestid
INNER JOIN workflow_nodebase n ON c.nodeid = n.id
INNER JOIN hrmresource h ON c.userid = h.id
-- WHERE条件可按需添加，例如指定流程ID或待办人
WHERE c.isremark = 0 and r.requestid=1308377
ORDER BY r.requestid;



 select * from workflow_currentoperator c where c.requestid=1308377  and isremark = 0    group by requestid

  select * from workflow_currentoperator c where id=20851449
  20851449


  SELECT TOP 1 WITH TIES
    requestid,
    userid
FROM [ecology9].[dbo].[workflow_currentoperator]
WHERE isremark = 0
ORDER BY ROW_NUMBER() OVER (PARTITION BY requestid ORDER BY userid DESC);

workflow_base - 工作流基础信息表

workflow_nodebase - 工作流节点表

workflow_flownode - 工作流流转节点表

hrmresource - 人力资源表(用户信息)


select top 10 * from workflow_groupinfo

select top 100 * from workflow_formbase

select top 100 * from workflow_requestbase - 流程实例表

存储所有流程实例的基本信息

select top 100 * from workflow_requestlog - 流程流转日志表

记录流程的流转历史

select top 100 * from workflow_formdict - 流程表单字典表

存储流程表单的字段定义

select top 100 * from workflow_billfield - 流程单据字段表





记录流程单据的字段信息
记录流程中的各个节点信息

# 泛微E9流程审批相关基础表结构

泛微E9的流程审批功能主要涉及以下几类基础表：

## 1. 流程主表

### workflow_requestbase (流程请求基础表)
- 存储所有流程实例的基本信息
- 关键字段：
  - `requestid`：流程实例ID（主键）
  - `workflowid`：流程模板ID
  - `requestname`：流程标题
  - `creater`：创建人ID
  - `createdate`：创建时间
  - `createtime`：创建时间(时分秒)
  - `lastoperator`：最后操作人
  - `lastoperatedate`：最后操作日期
  - `currentnodetype`：当前节点类型
  - `currentstatus`：当前状态(0草稿,1运行中,2已完成等)
  - `lastnodeid`：上一节点ID

## 2. 流程节点相关表

### workflow_flownode (流程节点定义表)
- 存储流程模板的所有节点定义
- 关键字段：
  - `id`：节点ID
  - `workflowid`：所属流程ID
  - `nodename`：节点名称
  - `nodetype`：节点类型(0开始,1常规,2结束,3汇聚等)
  - `isremark`：是否批注

### workflow_currentoperator (当前操作人表)
- 记录当前待办事项
- 关键字段：
  - `requestid`：流程实例ID
  - `userid`：待办人ID
  - `nodeid`：当前节点ID
  - `isremark`：是否已批注(0未处理,1已处理)
  - `isvalid`：是否有效(0无效,1有效)
  - `receivedate`：接收日期
  - `viewtype`：查看类型(1待办,2已办等)

### workflow_requestlog (流程操作日志表)
- 记录流程流转历史
- 关键字段：
  - `logid`：日志ID
  - `requestid`：流程实例ID
  - `nodeid`：节点ID
  - `operatedate`：操作日期
  - `operatetime`：操作时间
  - `operator`：操作人ID
  - `operatortype`：操作类型(0提交,1同意,2退回等)
  - `remark`：审批意见

## 3. 流程表单数据表

### workflow_formdetail (表单字段定义表)
- 存储流程表单的字段定义
- 关键字段：
  - `formid`：表单ID
  - `fieldid`：字段ID
  - `fieldname`：字段名称
  - `fielddbtype`：字段数据库类型

### workflow_requestform (流程表单数据表)
- 命名规则：`formtable_main`+表单ID
- 存储每个流程实例的表单数据
- 例如：`formtable_main_12`表示ID为12的表单数据

## 4. 其他相关表

### workflow_base (流程模板基础表)
- 存储所有流程模板定义
- 关键字段：
  - `id`：流程模板ID
  - `workflowname`：流程名称
  - `isvalid`：是否有效
  - `version`：版本号

### hrmresource (人力资源表)
- 存储用户基本信息
- 关键字段：
  - `id`：用户ID
  - `loginid`：登录账号
  - `lastname`：姓名
  - `departmentid`：部门ID

### workflow_bill (流程单据关联表)
- 存储流程与其他单据的关联关系
- 关键字段：
  - `requestid`：流程实例ID
  - `billid`：关联单据ID
  - `billtype`：单据类型

## 常用查询示例

```sql
-- 查询某流程的所有审批记录
SELECT * FROM workflow_requestlog 
WHERE requestid = [流程ID] 
ORDER BY operatedate, operatetime;

-- 查询用户待办事项(包含流程标题)
SELECT a.*, b.requestname 
FROM workflow_currentoperator a
JOIN workflow_requestbase b ON a.requestid = b.requestid
WHERE a.userid = [用户ID] AND a.isremark = 0 AND a.isvalid = 1;

-- 查询流程表单数据
SELECT * FROM formtable_main_[表单ID] 
WHERE requestid = [流程ID];
```

注意：实际表结构可能因E9版本不同有所差异，建议通过数据库工具直接查看您的系统数据库结构。